import config
import hashlib
import uuid

def encrypt(password, salt=config.salt):
    '''Adds a salt to "password" and hashes it''' 
    return hashlib.md5(password+salt+'5'+salt).hexdigest()

def valid_password(password, hash, salt=config.salt):
    '''Compares password to the hash'''
    return encrypt(password, salt) == hash

def unique_id():
    return str(uuid.uuid1().time)

def unique_name(label):
    return label + '_' + unique_id()

if __name__ == '__main__':
#    p = "thequickbrownfoxjumpsoverthelazydog"
#    h = encrypt(p,'test')
#    print 10, h
#    print 20, valid_password(p,h,'test')
#    print 30, valid_password(p,h) # false
#    h = encrypt(p)
#    print 40, h
#    print 50, valid_password(p,h)
#    print 60, valid_password(p,h,'test') # false
#    print 70, unique_id()
    print unique_name('user')
    
      